package com.gitee.wsl.collections.set

import androidx.collection.LongSet
import androidx.collection.MutableLongSet


/**
 * Returns an empty, read-only [LongSet].
 */
fun Sets.emptyLongSet(): LongSet = androidx.collection.emptyLongSet()


@Suppress("UNCHECKED_CAST")
fun Sets.longSetOf(): LongSet = androidx.collection.longSetOf()

/**
 * Returns a new read-only [LongSet] with only [element1] in it.
 */
@Suppress("UNCHECKED_CAST")
fun Sets.longSetOf(element1: Long): LongSet = mutableLongSetOf(element1)

/**
 * Returns a new read-only [LongSet] with only [element1] and [element2] in it.
 */
@Suppress("UNCHECKED_CAST")
fun Sets.longSetOf(element1: Long, element2: Long): LongSet =
    mutableLongSetOf(element1, element2)

/**
 * Returns a new read-only [LongSet] with only [element1], [element2], and [element3] in it.
 */
@Suppress("UNCHECKED_CAST")
fun Sets.longSetOf(element1: Long, element2: Long, element3: Long): LongSet =
    mutableLongSetOf(element1, element2, element3)

/**
 * Returns a new read-only [LongSet] with only [elements] in it.
 */
@Suppress("UNCHECKED_CAST")
fun Sets.longSetOf(vararg elements: Long): LongSet =
    MutableLongSet(elements.size).apply { plusAssign(elements) }

/**
 * Returns a new [MutableLongSet].
 */
fun Sets.mutableLongSetOf(): MutableLongSet = MutableLongSet()

/**
 * Returns a new [MutableLongSet] with only [element1] in it.
 */
fun Sets.mutableLongSetOf(element1: Long): MutableLongSet =
    MutableLongSet(1).apply {
        plusAssign(element1)
    }

/**
 * Returns a new [MutableLongSet] with only [element1] and [element2] in it.
 */
fun Sets.mutableLongSetOf(element1: Long, element2: Long): MutableLongSet =
    MutableLongSet(2).apply {
        plusAssign(element1)
        plusAssign(element2)
    }

/**
 * Returns a new [MutableLongSet] with only [element1], [element2], and [element3] in it.
 */
fun Sets.mutableLongSetOf(element1: Long, element2: Long, element3: Long): MutableLongSet =
    MutableLongSet(3).apply {
        plusAssign(element1)
        plusAssign(element2)
        plusAssign(element3)
    }

/**
 * Returns a new [MutableLongSet] with the specified elements.
 */
fun Sets.mutableLongSetOf(vararg elements: Long): MutableLongSet =
    MutableLongSet(elements.size).apply { plusAssign(elements) }
